<!--validtion form-->
<script>
	$(document).ready(function(){

		$("#userTypeForm").validate({
			rules : {
				typeName : { required : true, minlength: 2},
			},
			messages : {
				itemName : { required : 'Please enter user type', minlength:jQuery.format("At least {0} characters required!")},
			}
		});
	});
</script>
<?php include './pages/adminMenu.php'; ?>
<div class="mainContent">
	<div class = "masterData">
		<h3>Available User Types</h3>
		<?php
			include("./system/dbconnection.php");
			if($result =mysql_query("SELECT * FROM user_types ")){
				if(mysql_num_rows($result)){
					echo "<table border='1' cellspacing='0' width='100%' class='masterTable'>";
					echo "<tr><th>Type Id</th><th>Type Name</th><th>Type Description</th></tr>";
					while($row = mysql_fetch_array($result)){
						echo "<tr>";
						echo "<td>" . $row['typeId'] . "</td>";
						echo "<td>" . $row['typeName'] . "</td>";
						echo "<td>" . $row['typeDescription'] . "</td>";
						echo "</tr>";
					}
					echo "</table>";			
				}else{
					echo "No Data in Database";
				}	
			}
		?>	
	</div>
	<div class="mainForm">
		<form action="./system/action/addUserTypes.php" method="post" name="UserType" id="userTypeForm">
			<table cellspacing="10px" >
				<tr>
					<td colspan='2px'>
						<?php
						if(isset($_SESSION['error']) && $_SESSION['error'] != ""){ ?>
							<div class="error">
								<?php echo $_SESSION['error']; ?>
							</div>
						<?php } else if(isset($_SESSION['success']) && $_SESSION['success'] != ""){?>
							<div class="success">
								<?php echo $_SESSION['success']; ?>
							</div>
						<?php }
						?>					
					</td>				
				</tr>
				<tr>
					<td align="left">Type name<label class="mandatory">*</label></td>
					<td><input type="text" name="typeName" /></td>
				</tr>
				<tr>
					<td align="left">Type Description</td>
					<td><textarea name="typeDescription" rows="2" style="width:160px"></textarea></td>
				</tr>
				<tr >
					<td></td>
					<td align="left" ><button type="submit" ><img src="public/images/button-img/add.png"/><span> Add </span></button></td>
				</tr>
			</table>		
		</form>
	</div>
	
</div>